home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / cgazv4n3.zip / DROPMENU.HPP < prev    next >
C/C++ Source or Header  |  1990-02-05  |  1KB  |  35 lines

  1. // DROPMENU.HPP : Drop-down menus
  2. // by Bruce Eckel (C) C Gazette
  3.  
  4. class drop_menu; // class name declarations
  5. class screen_box;
  6.  
  7. class dm_item {
  8.     char * name;
  9.     char activation_letter;
  10.     unsigned actual_line; // physical start when printed
  11.     int (*fptr)(void);  // when activating a function
  12.     drop_menu * mptr;   // when activating a menu
  13.     void find_activation_letter();
  14.  public:
  15.     // an item can call a function or a menu:
  16.     dm_item(char * nm, int (*fp)(void));
  17.     dm_item(char * nm, drop_menu * submenu);
  18.     char * nm() { return name; }
  19.     void print(int line, screen_box & box);
  20.     void test_and_execute(unsigned keypress, drop_menu & menu);
  21. };
  22.  
  23. class drop_menu {
  24.     dm_item ** items;
  25.     unsigned mheight, mwidth;
  26.     unsigned default_x, default_y;  // default starting positions
  27.     unsigned actual_x, actual_y;    // actual starting positions
  28. public:
  29.     drop_menu(dm_item ** dm, unsigned xpos = 0, unsigned ypos = 0);
  30.     void activate(unsigned y = 0, unsigned x = 0);
  31.     void test_keypress(unsigned keypress);
  32.     unsigned y() { return actual_y; }
  33.     unsigned x() { return actual_x; }
  34.     unsigned width() { return mwidth; }
  35. };